import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PointsExchangeRuleQuery, PointsExchangeRuleVO, PointsExchangeRuleForm } from './types';

/**
 * 查询积分兑换规则列表
 */
export const listExchange = (query?: PointsExchangeRuleQuery): AxiosPromise<PointsExchangeRuleVO[]> => {
    return request({
        url: '/coupon/exchange/list',
        method: 'get',
        params: query
    });
};

/**
 * 获取积分兑换规则详细信息
 */
export const getExchange = (id: string | number): AxiosPromise<PointsExchangeRuleVO> => {
    return request({
        url: '/coupon/exchange/' + id,
        method: 'get'
    });
};

/**
 * 新增积分兑换规则
 */
export const addExchange = (data: PointsExchangeRuleForm) => {
    return request({
        url: '/coupon/exchange',
        method: 'post',
        data: data
    });
};

/**
 * 修改积分兑换规则
 */
export const updateExchange = (data: PointsExchangeRuleForm) => {
    return request({
        url: '/coupon/exchange',
        method: 'put',
        data: data
    });
};

/**
 * 删除积分兑换规则
 */
export const delExchange = (id: string | number | Array<string | number>) => {
    return request({
        url: '/coupon/exchange/' + id,
        method: 'delete'
    });
}; 